<template>
    <view class="content">
        <view class="top">
            <view class="title">{{data.items}}</view>
            <view class="time">{{data.date}}</view>
        </view>
        <view class="box">
            <u-parse :html="data.record"></u-parse>
            <view class="img-box">
                <image class="img" :src="el.image" v-for="(el, ind) in data.images" :key="ind" 
                     @click="doPreview(data.images, ind)"></image>
            </view>
            
            <!-- 用户对陪伴师的评价 -->
            <view class="u-p-t-30" v-if="data.evaluate_id != 0 && !fromServe">
                <view class="rate-top">
                    <u-rate :count="5" v-model="data.star" active-color="#fcc937" inactive-color="#f1f1f1" :disabled="true"></u-rate>
                    <view class="u-p-l-10">{{data.star}}星</view>
                    <view class="u-p-l-10">评分</view>
                </view>
                <view class="rate-down">
                    评价：<text>{{data.describes}}</text>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                id: '',
                data: {},
                fromServe: '',//1从服务人员进入的
            };
        },
        onLoad(option) {
            if (option.fromServe) {
                this.fromServe = option.fromServe
            }
            this.id = option.id
            this.getData()
        },
        methods: {
            //预览照片
            doPreview(item, index) {
                let arr = []
                item.forEach(cur => {
                    arr.push(cur.image)
                })
                uni.previewImage({
                    urls: arr,
                    current: index,
                    longPressActions: {
                        success: function(data) {
                        },
                        fail: function(err) {
                        }
                    }
                });
            },
            
            getData() {
            	this.$ajax('child_record_detail', {
            		user_token: this.$getSync('userToken'),
                    id: this.id,//学习记录id
            	}).then(ret => {
            		if (ret.success == 1000) {
                        this.data = ret.detail
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    .rate-top{
        display: flex;
        justify-content: flex-start;
        align-items: center;
        color: #000 !important;
    }
    .rate-down{
        padding-top: 15rpx;
        color: #000 !important;
    }
    .rate-down>text{
        word-break: break-all;
        white-space: pre-line;
    }
    
    page{
        background-color: #fff;
        border-top: 2rpx solid #eee;
    }
    .content{
        padding: 35rpx 25rpx;
    }
    .top{
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding-bottom: 35rpx;
        border-bottom: 2rpx solid #eee;
    }
    .title{
        font-size: 36rpx;
        font-weight: bold;
        padding-bottom: 10rpx;
    }
    .time{
        font-size: 24rpx;
        color: #666666;
    }
    .box{
        padding: 40rpx 0;
    }
    .img-box{
        padding-top: 30rpx;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        align-items: center;
    }
    .img{
        width: 220rpx;
        height: 220rpx;
        margin-right: 15rpx;
        margin-bottom: 15rpx;
    }
    .img:nth-child(3n) {
        margin-right: 0;
    }

</style>
